/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package communication.impl;

import communication.CommunicationPackage;
import communication.Parameter;
import communication.RestFulService;
import communication.Type;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Rest Ful Service</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link communication.impl.RestFulServiceImpl#getUrlMapping <em>Url Mapping</em>}</li>
 *   <li>{@link communication.impl.RestFulServiceImpl#getHttpMethod <em>Http Method</em>}</li>
 *   <li>{@link communication.impl.RestFulServiceImpl#getServiceClassName <em>Service Class Name</em>}</li>
 *   <li>{@link communication.impl.RestFulServiceImpl#getServiceName <em>Service Name</em>}</li>
 *   <li>{@link communication.impl.RestFulServiceImpl#getResponse <em>Response</em>}</li>
 *   <li>{@link communication.impl.RestFulServiceImpl#getParameters <em>Parameters</em>}</li>
 *   <li>{@link communication.impl.RestFulServiceImpl#getOperationName <em>Operation Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RestFulServiceImpl extends EObjectImpl implements RestFulService {
	/**
	 * The default value of the '{@link #getUrlMapping() <em>Url Mapping</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUrlMapping()
	 * @generated
	 * @ordered
	 */
	protected static final String URL_MAPPING_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getUrlMapping() <em>Url Mapping</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUrlMapping()
	 * @generated
	 * @ordered
	 */
	protected String urlMapping = URL_MAPPING_EDEFAULT;

	/**
	 * The default value of the '{@link #getHttpMethod() <em>Http Method</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHttpMethod()
	 * @generated
	 * @ordered
	 */
	protected static final String HTTP_METHOD_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getHttpMethod() <em>Http Method</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHttpMethod()
	 * @generated
	 * @ordered
	 */
	protected String httpMethod = HTTP_METHOD_EDEFAULT;

	/**
	 * The default value of the '{@link #getServiceClassName() <em>Service Class Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServiceClassName()
	 * @generated
	 * @ordered
	 */
	protected static final String SERVICE_CLASS_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getServiceClassName() <em>Service Class Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServiceClassName()
	 * @generated
	 * @ordered
	 */
	protected String serviceClassName = SERVICE_CLASS_NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getServiceName() <em>Service Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServiceName()
	 * @generated
	 * @ordered
	 */
	protected static final String SERVICE_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getServiceName() <em>Service Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServiceName()
	 * @generated
	 * @ordered
	 */
	protected String serviceName = SERVICE_NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getResponse() <em>Response</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResponse()
	 * @generated
	 * @ordered
	 */
	protected Type response;

	/**
	 * The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParameters()
	 * @generated
	 * @ordered
	 */
	protected EList<Parameter> parameters;

	/**
	 * The default value of the '{@link #getOperationName() <em>Operation Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperationName()
	 * @generated
	 * @ordered
	 */
	protected static final String OPERATION_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getOperationName() <em>Operation Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperationName()
	 * @generated
	 * @ordered
	 */
	protected String operationName = OPERATION_NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RestFulServiceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CommunicationPackage.Literals.REST_FUL_SERVICE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getUrlMapping() {
		return urlMapping;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUrlMapping(String newUrlMapping) {
		String oldUrlMapping = urlMapping;
		urlMapping = newUrlMapping;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.REST_FUL_SERVICE__URL_MAPPING, oldUrlMapping, urlMapping));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getHttpMethod() {
		return httpMethod;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHttpMethod(String newHttpMethod) {
		String oldHttpMethod = httpMethod;
		httpMethod = newHttpMethod;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.REST_FUL_SERVICE__HTTP_METHOD, oldHttpMethod, httpMethod));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getServiceName() {
		return serviceName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setServiceName(String newServiceName) {
		String oldServiceName = serviceName;
		serviceName = newServiceName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.REST_FUL_SERVICE__SERVICE_NAME, oldServiceName, serviceName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getServiceClassName() {
		return serviceClassName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setServiceClassName(String newServiceClassName) {
		String oldServiceClassName = serviceClassName;
		serviceClassName = newServiceClassName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.REST_FUL_SERVICE__SERVICE_CLASS_NAME, oldServiceClassName, serviceClassName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getOperationName() {
		return operationName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOperationName(String newOperationName) {
		String oldOperationName = operationName;
		operationName = newOperationName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.REST_FUL_SERVICE__OPERATION_NAME, oldOperationName, operationName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Type getResponse() {
		if (response != null && response.eIsProxy()) {
			InternalEObject oldResponse = (InternalEObject)response;
			response = (Type)eResolveProxy(oldResponse);
			if (response != oldResponse) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommunicationPackage.REST_FUL_SERVICE__RESPONSE, oldResponse, response));
			}
		}
		return response;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Type basicGetResponse() {
		return response;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setResponse(Type newResponse) {
		Type oldResponse = response;
		response = newResponse;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationPackage.REST_FUL_SERVICE__RESPONSE, oldResponse, response));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Parameter> getParameters() {
		if (parameters == null) {
			parameters = new EObjectContainmentEList<Parameter>(Parameter.class, this, CommunicationPackage.REST_FUL_SERVICE__PARAMETERS);
		}
		return parameters;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CommunicationPackage.REST_FUL_SERVICE__PARAMETERS:
				return ((InternalEList<?>)getParameters()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CommunicationPackage.REST_FUL_SERVICE__URL_MAPPING:
				return getUrlMapping();
			case CommunicationPackage.REST_FUL_SERVICE__HTTP_METHOD:
				return getHttpMethod();
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_CLASS_NAME:
				return getServiceClassName();
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_NAME:
				return getServiceName();
			case CommunicationPackage.REST_FUL_SERVICE__RESPONSE:
				if (resolve) return getResponse();
				return basicGetResponse();
			case CommunicationPackage.REST_FUL_SERVICE__PARAMETERS:
				return getParameters();
			case CommunicationPackage.REST_FUL_SERVICE__OPERATION_NAME:
				return getOperationName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CommunicationPackage.REST_FUL_SERVICE__URL_MAPPING:
				setUrlMapping((String)newValue);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__HTTP_METHOD:
				setHttpMethod((String)newValue);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_CLASS_NAME:
				setServiceClassName((String)newValue);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_NAME:
				setServiceName((String)newValue);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__RESPONSE:
				setResponse((Type)newValue);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__PARAMETERS:
				getParameters().clear();
				getParameters().addAll((Collection<? extends Parameter>)newValue);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__OPERATION_NAME:
				setOperationName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CommunicationPackage.REST_FUL_SERVICE__URL_MAPPING:
				setUrlMapping(URL_MAPPING_EDEFAULT);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__HTTP_METHOD:
				setHttpMethod(HTTP_METHOD_EDEFAULT);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_CLASS_NAME:
				setServiceClassName(SERVICE_CLASS_NAME_EDEFAULT);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_NAME:
				setServiceName(SERVICE_NAME_EDEFAULT);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__RESPONSE:
				setResponse((Type)null);
				return;
			case CommunicationPackage.REST_FUL_SERVICE__PARAMETERS:
				getParameters().clear();
				return;
			case CommunicationPackage.REST_FUL_SERVICE__OPERATION_NAME:
				setOperationName(OPERATION_NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CommunicationPackage.REST_FUL_SERVICE__URL_MAPPING:
				return URL_MAPPING_EDEFAULT == null ? urlMapping != null : !URL_MAPPING_EDEFAULT.equals(urlMapping);
			case CommunicationPackage.REST_FUL_SERVICE__HTTP_METHOD:
				return HTTP_METHOD_EDEFAULT == null ? httpMethod != null : !HTTP_METHOD_EDEFAULT.equals(httpMethod);
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_CLASS_NAME:
				return SERVICE_CLASS_NAME_EDEFAULT == null ? serviceClassName != null : !SERVICE_CLASS_NAME_EDEFAULT.equals(serviceClassName);
			case CommunicationPackage.REST_FUL_SERVICE__SERVICE_NAME:
				return SERVICE_NAME_EDEFAULT == null ? serviceName != null : !SERVICE_NAME_EDEFAULT.equals(serviceName);
			case CommunicationPackage.REST_FUL_SERVICE__RESPONSE:
				return response != null;
			case CommunicationPackage.REST_FUL_SERVICE__PARAMETERS:
				return parameters != null && !parameters.isEmpty();
			case CommunicationPackage.REST_FUL_SERVICE__OPERATION_NAME:
				return OPERATION_NAME_EDEFAULT == null ? operationName != null : !OPERATION_NAME_EDEFAULT.equals(operationName);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (urlMapping: ");
		result.append(urlMapping);
		result.append(", httpMethod: ");
		result.append(httpMethod);
		result.append(", serviceClassName: ");
		result.append(serviceClassName);
		result.append(", serviceName: ");
		result.append(serviceName);
		result.append(", operationName: ");
		result.append(operationName);
		result.append(')');
		return result.toString();
	}

} //RestFulServiceImpl
